<template>
	<view class="medicalCardBox">
		<view class="title">左右滑动二维码可切换就诊人</view>
		<view class="cardList">
			<view class="userInfo">
				<view class="top">
					<view class="name">{{qrSwiperList[cardIndex].name}}</view>
					<view class="balance">余额:¥{{qrSwiperList[cardIndex].balance}}</view>
				</view>
				<view class="card">就诊卡号:{{qrSwiperList[cardIndex].cardNo}}</view>
			</view>
			<view class="qrSwiper">
				<u-swiper height="282rpx" @change="changeCard" @click="qrCodePreviewImage" :list="qrSwiperList"
					keyName="image" :autoplay="false" circular imgMode></u-swiper>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 当前卡片索引
				cardIndex: 0,
				//就诊人信息列表
				qrSwiperList: [{
					image: 'https://s3.bmp.ovh/imgs/2022/08/22/dc720e5d0256c3dd.png',
					name: '张三',
					balance: '300',
					cardNo: '85245685296311245'
				}, {
					image: 'https://s3.bmp.ovh/imgs/2022/08/22/dc720e5d0256c3dd.png',
					name: '李四',
					balance: '120',
					cardNo: '85245685296311246'
				}, {
					image: 'https://s3.bmp.ovh/imgs/2022/08/22/dc720e5d0256c3dd.png',
					name: '王五',
					balance: '200',
					cardNo: '85245685296311247'
				}],
			}
		},
		methods: {
			//改变电子就诊卡
			changeCard(data) {
				this.cardIndex = data.current
			},
			qrCodePreviewImage(e) {
				console.log(e)
				uni.previewImage({
					urls: [this.qrSwiperList[e].image],
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {},
						fail: function(err) {}
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.medicalCardBox {
		width: 100%;
		height: 100%;

		.title {
			height: 68rpx;
			background: linear-gradient(84deg, #518AFD 0%, #62BBF8 100%);
			opacity: 0.7;
			font-size: 32rpx;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.cardList {
			width: 462rpx;
			height: 474rpx;
			margin: 38rpx auto 0;
			box-shadow: 5px 5px 5px #F7F7F7;
			border: 1px solid #F7F7F7;
			border-radius: 14rpx;
			padding: 48rpx;

			.userInfo {
				color: #000000;
				font-size: 36rpx;

				.top {
					display: flex;
					margin-bottom: 12rpx;

					.name {
						margin-right: 36rpx;
						font-weight: bold;
						letter-spacing: 4px;
					}

					.balance {
						color: #565656;
						align-self: flex-end;
						font-size: 28rpx;
					}
				}

				.card {
					font-size: 30rpx;
				}
			}

			.qrSwiper {
				width: 282rpx;
				height: 282rpx;
				margin: 50rpx auto 0;
			}
		}
	}
</style>
